package com.yanfan.zutai.controller;

import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.zutai.aop.SysInitData;
import com.yanfan.zutai.aop.SysInitUpdateData;
import com.yanfan.zutai.aop.SysQueryData;
import com.yanfan.zutai.domain.BDeviceDrive;
import com.yanfan.zutai.service.IBDeviceDriveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 设备驱动管理Controller
 *
 * @author ruoyi
 * @date 2023-06-10
 */
@RestController
@RequestMapping("/zutai/bDeviceDrive")
public class BDeviceDriveController extends BaseController {
    @Autowired
    private IBDeviceDriveService bDeviceDriveService;

    /**
     * 查询设备驱动管理列表
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceDrive:list')")
    @GetMapping("/list")
    @SysQueryData
    public TableDataInfo list(BDeviceDrive bDeviceDrive) {
        startPage();
        List<BDeviceDrive> list = bDeviceDriveService.selectBDeviceDriveList(bDeviceDrive);
        return getDataTable(list);
    }

    /**
     * 导出设备驱动管理列表
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceDrive:export')")
    @Log(title = "设备驱动管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BDeviceDrive bDeviceDrive) {
        List<BDeviceDrive> list = bDeviceDriveService.selectBDeviceDriveList(bDeviceDrive);
        ExcelUtil<BDeviceDrive> util = new ExcelUtil<BDeviceDrive>(BDeviceDrive.class);
        util.exportExcel(response, list, "设备驱动管理数据");
    }

    /**
     * 获取设备驱动管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceDrive:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(bDeviceDriveService.selectBDeviceDriveById(id));
    }

    /**
     * 新增设备驱动管理
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceDrive:add')")
    @Log(title = "设备驱动管理", businessType = BusinessType.INSERT)
    @PostMapping
    @SysInitData
    public AjaxResult add(@RequestBody BDeviceDrive bDeviceDrive) {
        return toAjax(bDeviceDriveService.insertBDeviceDrive(bDeviceDrive));
    }

    /**
     * 修改设备驱动管理
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceDrive:edit')")
    @Log(title = "设备驱动管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @SysInitUpdateData
    public AjaxResult edit(@RequestBody BDeviceDrive bDeviceDrive) {
        return toAjax(bDeviceDriveService.updateBDeviceDrive(bDeviceDrive));
    }

    /**
     * 删除设备驱动管理
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceDrive:remove')")
    @Log(title = "设备驱动管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bDeviceDriveService.deleteBDeviceDriveByIds(ids));
    }
}
